#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2022/11/4 17:01
# @Author  : TangZhongZheng
# @File    : main.py
# @Description :
import sys

import pygame

from settings import *
from src.level import Level


class Game:
    def __init__(self):
        pygame.init()
        self.screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
        pygame.display.set_caption("Manor Tale")
        # pygame.display.set_icon(pygame.image.load("../resource/graphics/objects/tree_medium.png"))
        self.clock = pygame.time.Clock()
        self.level = Level()

    def run(self):
        while True:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.quit()
                    sys.exit()
                elif event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_ESCAPE:
                        pygame.quit()
                        sys.exit()
            dt = self.clock.tick()/1000
            self.level.run(dt)
            pygame.display.update()


if __name__ == '__main__':
    game = Game()
    game.run()
